package cn.ubeta.b2c.api;

import cn.ubeta.b2c.bean.CartCheckProductInfo;
import cn.ubeta.b2c.bean.CartInfo;
import cn.ubeta.b2c.utils.NetworkCallback;
import cn.ubeta.b2c.utils.NetworkHelper;

import java.util.List;

/**
 * Created by liudengyong on 16/8/29.
 */

public class ApiCart {

    private static final String PATH = "/cart";

    /**
     * 获取购物车商品列表
     * @param cb
     */
    public static void getCartProductList(NetworkCallback<List<CartInfo.CartProductInfo>> cb) {
        List<CartInfo.CartProductInfo> test = CartInfo.CartProductInfo.getTestData();
        if (test != null) {
            cb.onResponse(test);
        } else {
            NetworkHelper.call(PATH + "/list", cb);
        }
    }

    /**
     * 购物车勾选商品
     * @param skuId
     * @param checked
     * @param cb
     */
    public static void cartCheckProduct(long skuId, boolean checked, NetworkCallback cb) {
        CartCheckProductInfo test = CartCheckProductInfo.getTest(skuId, checked);
        if (test != null) {
            cb.onResponse(test);
        } else {
            String url = String.format("/checkProduct?skuId=%d&checked=%s", skuId, checked);
            NetworkHelper.call(PATH + url, cb);
        }
    }

}
